- content_for :meta do
  %meta{:name => "Description", :content => "These photo and video galleries demonstrate the work of Dan Stewart"}
  %meta{:name => "Abstract", :content => "Dan Stewart's photo galleries"}
  %meta{:name => "Keywords", :content => "Photo Galleries, Dan Stewart, Photography, Suttons Bay, Northern Michigan"}
- content_for :title do
  galleries
- content_for :head do
  = javascript_include_tag  'mootools-1.2.1-core.js'
  = javascript_include_tag  'mootools-1.2-more.js'
  = stylesheet_link_tag 'pagination'
  %script{:type => "text/javascript"}
    = "window.addEvent('domready', function() {"
    = " var stretchers = $$('div.sorting_elements');"
    = " var togglers = $$('a.filter');"
    = " var accordion = new Accordion(togglers, stretchers, {"
    = "   alwaysHide:true,"
    = params[:filter] ? "   display:0," : "   display:99,"
    = "   opacity: true"
    = " }, $('content'));"
    = "});"
%h1.page_title Galleries
- if logged_in? and current_user.is_admin?
  %div.filter
    %a.filter Filter
    %div.sorting_elements
      - form_tag galleries_url, :method => 'GET' do
        %ul.sortables_list
          %li
            %select{:name => "filter[gallery_attribute]"}
              %option{:value => ''} Sort by
              %option{:value => ''} ---------
              %option{:value => ''} Sort by anything
              - sortable_gallery_attributes.each do |attribute|
                %option{:value => attribute, :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:gallery_attribute] == attribute)))}= attribute.gsub("_", " ").capitalize
          %li
            %select{:name => "filter[gallery_attribute_order]"}
              %option{:value => ''} In order
              %option{:value => ''} ---------
              %option{:value => ''} In any order
              %option{:value => 'desc', :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:gallery_attribute_order] == "desc")))}Descending
              %option{:value => 'asc', :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:gallery_attribute_order] == "asc")))}Ascending
          %li
            %select{:name => "filter[boolean_gallery_attribute]"}
              %option{:value => ''} With option
              %option{:value => ''} ---------
              %option{:value => ''} With any option
              - filterable_boolean_gallery_attributes.each do |attribute|
                %option{:value => attribute, :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:boolean_gallery_attribute] == attribute)))}= attribute.gsub("_", " ").capitalize
          %li
            %select{:name => "filter[price_list]"}
              %option{:value => 'all', :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:price_list] == "all")))} With price list
              %option{:value => 'all', :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:price_list] == "all")))} ---------
              %option{:value => 'all', :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:price_list] == "all")))} Any price list
              %option{:value => '', :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:price_list].blank?)))} Not purchasable
              - @price_lists.each do |price_list|
                %option{:value => price_list.id, :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:price_list] == price_list.id.to_s)))}= price_list.name.gsub("_", " ").capitalize
          %li
            %select{:name => "filter[gallery_template]"}
              %option{:value => ''} With Template
              %option{:value => ''} ---------
              - @gallery_templates.each do |gallery_template|
                %option{:value => gallery_template.id, :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:gallery_template] == gallery_template.id.to_s)))}= gallery_template.name.gsub("_", " ").capitalize
          %li
            %select{:name => "filter[page]"}
              %option{:value => ''} On page
              %option{:value => ''} ---------
              - @pages.each do |page|
                %option{:value => page.id, :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:page] == page.id.to_s)))}= page.title.capitalize
          %li
            %select{:name => "filter[user]"}
              %option{:value => ''} For client
              %option{:value => ''} ---------
              - @users.each do |user|
                %option{:value => user.id, :selected => ('selected' if (params[:filter].nil? ? false : (params[:filter][:user] == user.id.to_s)))}= user.login.capitalize
          %li
            = submit_tag 'go'
%hr.seperator{:style => "margin-left: 20px;"}
%div.galleries
  - @galleries.each do |gallery|
    %table.index_gallery
      %tr
        %td.gallery_preview
          %a{:href => gallery_url(gallery), :title => gallery.text_description}
            %img.photo_thumb{:src => gallery.thumbnail, :title => gallery.text_description}
      %tr
        %td.gallery_name= gallery.name
%div.pagination
  = will_paginate @galleries, :class => "flickr_pagination"
  %div.page_info
    = page_entries_info @galleries